<template>
  <div class="resource-import-button">
    <el-upload
      ref="elUpload"
      :multiple="false"
      :show-file-list="false"
      :http-request="uploadFileMethod"
      :before-upload="beforeUpload"
      :disabled="isDisabled"
      accept=".xls,.xlsx"
      action
      class="file-uploader"
    >
      <el-button
        :loading="loading"
        :style="btnStyle"
        class="el-btn loading-absolute"
        type="primary"
        size="small">{{ btnText }} <img :src="ImportIcon" style="width:16px;height: 16px;" > </el-button>
    </el-upload>
  </div>
</template>
<script>
import ImportList from './mixin/importList';
import ImportIcon from '@/assets/medium/import-data.png';

export default {
  name: 'ImportButton',
  mixins: [ImportList],
  props: {
    isNeedBaseFiled: {
      type: Boolean,
      default: true
    },
    radioList: {
      type: Object,
      default: () => {
        return {};
      }
    },
    // 按钮文字
    btnText: {
      type: String,
      default: '导入excel'
    },
    btnStyle: {
      type: Object,
      default: () => {
        return {};
      }
    },
    // 控制是否显示成功和失败提示框
    hideConfirm: {
      type: Boolean,
      default: false
    },
    showIcon: {
      type: Boolean,
      default: false
    },
    // 是否可以点击
    isDisabled: {
      type: Boolean,
      default: false
    },
    isMedium: {
      type: Boolean,
      default: false
    },
    importApi: {
      type: String,
      default: () => {
        return '';
      }
    },
    getList: { // 导入后列表刷新的方法
      type: Function,
      default: null
    }
  },
  data() {
    return {
      ImportIcon,
      isSealing: false,
      limitNum: false
    };
  }
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.resource-import-button {
  .el-btn {
    padding: 8px 24px;
    img {
      margin-left: 8px;
    }
  }
  .btn-import {
    position: relative;
    .progress-text {
      display: inline-block;
      height: 22px;
      position: absolute;
      left: -36px;
      top: 4px;
    }
    // .el-icon-loading {
    //   position: absolute;
    //   top: 4px;
    //   left: -10px;
    // }
    img {
      width: 19px;
      height: 18px;
    }
  }
  .loading-absolute {
    width: 120px;
    height: 32px;
    & ::v-deep {
      span {
        display: flex;
        align-items: center;
      }
      .el-icon-loading {
        position: absolute;
        left: 10px;
      }
    }
  }
}
.medium-import-btn-container {
  padding-top: 0;
  .file-uploader {
    margin: 0;
  }
}
.medium-import-btn {
  font-size: 12px;
  color: #333333;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  height: 30px;
  background-color: #ffffff;
  border-radius: 50px 50px 50px 50px;
  border: solid 1px #e5e5e5;
  margin-left: 10px;
  font-weight: normal;
  cursor: pointer;
  &.hover:hover {
    color: #6e8fa2;
    border-color: #e5e5e5;
    background-color: #ffffff;
  }
  img {
    width: 13px;
    height: 12px;
    margin-right: 5px;
  }
}
.imprt-tooltip {
  padding: 5px 10px;
}
</style>
